Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socketโs threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
framer-motion
Advanced tools
The framer-motion npm package is a popular library for creating animations and transitions in React applications. It provides a powerful and easy-to-use set of tools for animating components, handling gestures, and creating complex motion effects with simple declarative syntax.
Basic Animations
Animate the horizontal position of a component to 100 pixels.
{"<motion.div animate={{ x: 100 }} />"}
Variants
Use variants to define animation states and transition between them.
{"<motion.div variants={variants} initial='hidden' animate='visible' />"}
Gestures
Scale a button up on hover and down on tap.
{"<motion.button whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }} />"}
Drag
Make a component draggable.
{"<motion.div drag />"}
Shared Layout Animations
Animate layout changes between components that share a layoutId.
{"<motion.ul layout><motion.li layoutId='id' /></motion.ul>"}
Exit Animations
Animate the component out when it's removed from the React tree.
{"<motion.div exit={{ opacity: 0 }} />"}
React-spring is a spring-physics based animation library that allows for a wide range of animations in React applications. It is similar to framer-motion in that it provides a way to create animations, but it uses spring physics for a more natural motion. React-spring is more focused on physics-based animations, whereas framer-motion offers a wider range of animation utilities, including gesture handling and drag.
React-motion is another animation library for React that provides a powerful way to create animations using spring configurations. It is less declarative and more configuration-based compared to framer-motion, which might be preferred by developers who want more control over the animation physics.
GSAP (GreenSock Animation Platform) is a robust JavaScript animation library that works well with React and other frameworks. It is not specifically designed for React like framer-motion, but it offers a wide range of animation capabilities and fine-grained control over animations. GSAP is known for its performance and flexibility, but it has a steeper learning curve compared to framer-motion.
Anime.js is a lightweight JavaScript animation library that can be used with any web framework, including React. It is similar to framer-motion in terms of providing a simple API for animations, but it does not offer React-specific features like framer-motion does. Anime.js is a good choice for developers looking for a general-purpose animation library that is easy to use and extend.
Framer Motion is an open source, production-ready library thatโs designed for all creative developers.
It looks like this:
<motion.div animate={{ x: 0 }} />
It does all this:
...and a whole lot more.
Install framer-motion
with via your package manager:
npm install framer-motion
Then import the motion
component:
import { motion } from "framer-motion"
export const MyComponent = ({ isVisible }) => (
<motion.div animate={{ opacity: isVisible ? 1 : 0 }} />
)
[7.10.3] 2022-12-20
animateChanges
in useLayoutEffect
rather than useEffect
to ensure optimised appear animations are handed off before paint.FAQs
A simple and powerful JavaScript animation library
The npm package framer-motion receives a total of 3,831,573 weekly downloads. As such, framer-motion popularity was classified as popular.
We found that framer-motion demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.ย It has 51 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socketโs threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.